package Thread;

public class ThreadDemo24 {
    private static int res = 0;
    public synchronized static void print() {
        System.out.println(res++);
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t4 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t5 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t6 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t7 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t8 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t9 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t10 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t11 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t12 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t13 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t14 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t15 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t16 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t17 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t18 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t19 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        Thread t20 = new Thread(new Runnable() {
            @Override
            public void run() {
                ThreadDemo24.print();
            }
        });
        t1.start();
        t2.start();
        t3.start();
        t4.start();
        t5.start();
        t6.start();
        t7.start();
        t8.start();
        t9.start();
        t10.start();
        t11.start();
        t12.start();
        t13.start();
        t14.start();
        t15.start();
        t16.start();
        t17.start();
        t18.start();
        t19.start();
        t20.start();

        Thread.sleep(100);
        System.out.println("ok");
    }

}
